﻿
/*----------------------------------------------------------------
 * 创建时间：2023/8/3 11:06:43
 * 作  者：wenlli 
 * 项  目：Minotaur.App.Core 
 * 描  述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时  间：
 * 修改说明：
 * 
 *----------------------------------------------------------------*/


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Minotaur.App.Core
{

    /// <summary>
    /// 进行
    /// </summary>
    public static class HashUtilsHelper
    {
        public static long GetHashCode(this string text)
        {
            if (string.IsNullOrEmpty(text)) return 0;
            byte[] bytes = Encoding.Unicode.GetBytes(text);
            byte[] hashText = new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash(bytes);
            uint hashCodeStart = BitConverter.ToUInt32(hashText, 0);
            uint hashCodeMedium = BitConverter.ToUInt32(hashText, 8);
            uint hashCodeEnd = BitConverter.ToUInt32(hashText, 16);
            var hashCode = hashCodeStart ^ hashCodeMedium ^ hashCodeEnd;
            return long.MaxValue - hashCode;
        }

        /// <summary>
        /// 获取长整型随机数
        /// </summary>
        /// <returns></returns>
        public static long GetLongHashCode()
        {
            return (long)Math.Floor((new Random()).NextDouble() * 100000000000D);
        }
    }
}
